/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package vn.edu.hcmut.cse.ai.search.problems.waterjug;

import java.util.LinkedList;
import java.util.List;
import vn.edu.hcmut.cse.ai.infrastructure.Action;
import vn.edu.hcmut.cse.ai.infrastructure.Actions;

public class WaterActions implements Actions {

    @Override
    public List<Action> getActionList(Object state) {
        List<Action> actionList = new LinkedList<>();
        WaterState waterState = (WaterState) state;
        if (waterState.empty1()) {
            WaterAction empty = new WaterAction(WaterActionType.EMPTY1);
            actionList.add(empty);
            waterState.undoEmpty1();
            waterState.clearUndo();
        }
        if (waterState.empty2()) {
            WaterAction empty = new WaterAction(WaterActionType.EMPTY2);
            actionList.add(empty);
            waterState.undoEmpty2();
            waterState.clearUndo();
        }
        if (waterState.fill1()) {
            WaterAction fill = new WaterAction(WaterActionType.FILL1);
            actionList.add(fill);
            waterState.undoFill1();
            waterState.clearUndo();
        }
        if (waterState.fill2()) {
            WaterAction fill = new WaterAction(WaterActionType.FILL2);
            actionList.add(fill);
            waterState.undoFill2();
            waterState.clearUndo();
        }
        if (waterState.fill1from2()) {
            WaterAction fillf = new WaterAction(WaterActionType.FILL1FROM2);
            actionList.add(fillf);
            waterState.undoFill1From2();
            waterState.clearUndo();
        }
        if (waterState.fill2from1()) {
            WaterAction fillf = new WaterAction(WaterActionType.FILL2FROM1);
            actionList.add(fillf);
            waterState.undoFill2From1();
            waterState.clearUndo();
        }
        if (waterState.pourAll1to2()) {
            WaterAction p = new WaterAction(WaterActionType.POURALL1TO2);
            actionList.add(p);
            waterState.undoPourAll1to2();
            waterState.clearUndo();
        }
        if (waterState.pourAll2to1()) {
            WaterAction p = new WaterAction(WaterActionType.POURALL2TO1);
            actionList.add(p);
            waterState.undoPourAll2to1();
            waterState.clearUndo();
        }
        return actionList;
    }

}
